//
//  TTAppDelegate.m
//  Tint
//
//  Created by Kevin Wu on 2/22/12.
//  Copyright (c) 2012 Telligenty. All rights reserved.
//

#import "TTAppDelegate.h"


@implementation TTAppDelegate


#pragma mark - Accessors

@synthesize window = _window;


#pragma mark - Memory

- (void)dealloc {
    TTRelease(_window);
    [super dealloc];
}


#pragma mark - Public

+ (id)sharedObject {
    return [UIApplication sharedApplication].delegate;
}


#pragma mark - To override

- (UIWindow *)mainWindow {
    UIWindow *window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    window.backgroundColor = [UIColor whiteColor];
    return [window autorelease];
}

- (UIViewController *)mainViewController {
    return nil;
}

- (void)windowWillShow {
    if (TTIsFirstLaunch()) {
        [self windowWillShowFirstTime];
    }
}

- (void)windowDidShow {
    if (TTIsFirstLaunch()) {
        [self windowDidShowFirstTime];
    }
    TTIncreaseLaunchTimes();
}

- (void)windowWillShowFirstTime {
}

- (void)windowDidShowFirstTime {
}

- (BOOL)shouldShowStatusBar {
    return YES;
}

- (UIStatusBarStyle)statusBarStyle {
    return UIStatusBarStyleDefault;
}


#pragma mark - UIApplicationDelegate

/*
 * Override this function, call super, and code like this:
 * 
 * [super application:application didFinishLaunchingWithOptions:launchOptions];
 * 
 * [self windowWillShow];
 * 
 * self.window = [self mainWindow];
 * self.window.rootViewController = [self mainViewController];
 * [self.window makeKeyAndVisible];
 * 
 * [self windowDidShow]; // Can move this into applicationDidBecomeActive:
 * 
 */
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    ////////////////////////////////////////////////////////////////////////////
    // Status bar
    if ([self shouldShowStatusBar]) {
        [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
        [[UIApplication sharedApplication] setStatusBarStyle:[self statusBarStyle] animated:NO];
    } else {
        [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
    }
    ////////////////////////////////////////////////////////////////////////////
    
    return YES;
}

@end
